home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr35
/
shift103.zip
/
SHIFTEM.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-04-20
|
5KB
|
183 lines
Program Shiftem;
{
****************************************************************************
Multiline support for Binkley (checking and generation of .BSY files) will
be coming soon once I have finished the other projects I'm working on.
At the moment running in a busy multiline environment could seriously damage
your .?LO files.
****************************************************************************
1.02 15/05/93 Added support for Zmail which seems to use a non standard
LF for end of line instead of the more usual CR+LF!
1.03 19/05/93 Added support for Binkley Multiline .BSY flags.
}
Uses Dos;
Const
ProgName = 'ShiftEm';
Vers = '1.03';
Date = 'Mon 19th April 1993';
MaxDirSize = 512;
type
TextPtr = ^TextRec;
TextRec = record
Txtline : String;
end;
DirPtr = ^DirRec;
DirRec = record
Attr: Byte;
Time: Longint;
Size: Longint;
Name: string[12];
end;
DirList = array[0..MaxDirSize - 1] of DirPtr;
TextList = array[0..999] of TextPtr;
Var
ScanPath : PathStr;
TxtCnt,
Count : Integer;
Txt : TextList;
Dir : DirList;
Procedure DoWork(Spath : PathStr);
procedure FindFiles;
var
F: SearchRec;
begin
Count := 0;
FindFirst(SPath, Archive, F);
while (DosError = 0) and (Count < MaxDirSize) do
begin
GetMem(Dir[Count], Length(F.Name) + 10);
Move(F.Attr, Dir[Count]^, Length(F.Name) + 10);
Inc(Count);
FindNext(F);
end;
end;
Var
t : Text;
b : File;
i, j, k : Integer;
s : String;
ArcMail,
Change : Boolean;
DirInfo : SearchRec;
D : DirStr;
N : NameStr;
E : ExtStr;
begin
FindFiles;
If Count = 0 then
begin
WriteLn;
WriteLn('Nothing to Do!!!');
Halt(2);
end;
For i := 0 to Count -1 do
Begin
Fsplit(ScanPath+Dir[i]^.Name, D, N, E);
FindFirst(D+N+'.BSY', Archive, Dirinfo);
if ((DosError = 2) or (DosError = 18)) then
Begin
FileMode:=$21; {DenyWrite - Write Only}
Assign(b, D+N+'.BSY');
{$I-} Rewrite(b); {$I+}
if IOResult = 0 then
Begin
TxtCnt:=0;
Assign(t, D+N+E);
FileMode:=$42; {DenyNone - Read/Write}
{$I-} Reset(t); {$I+}
if IOResult = 0 then
While (Not Eof(t)) do
Begin
Readln(t, S);
While (S <> '') do
Begin
New(Txt[TxtCnt]);
k := pos(#10,S);
if k <> 0 then
Begin
Txt[TxtCnt]^.TxtLine := Copy(S,1,k-1);
S := Copy(S,k+1,Length(s)-k);
end {if k <> 0}
else
Begin
Txt[TxtCnt]^.TxtLine := S;
S := '';
end; {if k <> 0}
Inc(TxtCnt);
end; {While S <> ''}
end; {While Not Eof(t)}
k:=0;
Change:=False;
if TxtCnt <> 0 then
for j := 0 to TxtCnt -1 do
Begin
S := Copy(Txt[j]^.Txtline,Length(Txt[j]^.Txtline)-2,2);
S := Upcase(S[1]) + Upcase(S[2]);
if (S = 'MO') or
(S = 'TU') or
(S = 'WE') or
(S = 'TH') or
(S = 'FR') or
(S = 'SA') or
(S = 'SU') or
(S = 'TZ') then ArcMail := True
else ArcMail:=False;
if ArcMail and (j = k) then Inc(k);
If ArcMail and (J > K) then
Begin
S:= Txt[k]^.Txtline;
Txt[k]^.TxtLine := Txt[j]^.TxtLine;
Txt[j]^.TxtLine := S;
Inc(k);
Change:=True;
end; {if Arcmail and J > K}
end; {For}
if Change then
Begin
Rewrite(t);
For j := 0 to TxtCnt -1 do
WriteLn(t,Txt[j]^.TxtLine);
While ((TxtCnt-1) <> 0) do
Begin
Dispose(Txt[TxtCnt-1]);
Dec(TxtCnt);
end; {While}
end; {if Change}
Close(t);
end; {if IOResult = 0}
Close(b);
Erase(b);
end; {If DOSerror = 0}
end; {For i := 0 to Count}
end; {DoWork}
Procedure Usage;
begin
Writeln('Usage: ');
WriteLn('Progname <Drive:path\> of outbound area to scan.');
WriteLn;
Halt(1);
end;
begin
Writeln;
Writeln(ProgName+' Vers: '+vers+' Compiled: '+Date+' (C) Dave Gorski');
if Paramcount <> 1 then usage;
ScanPath := ParamStr(1);
if ScanPath[length(ScanPath)] <> '\' then
ScanPath := ScanPath + '\';
dowork(ScanPath+'*.?LO');
end.